#include "data/data_helper.hpp"

#include <fstream>
#include <utils/path_utils.hpp>

bool LoadSaveFile::LoadFile(const char *file_name, Json &j) {
    std::string path = GetDataPath(file_name);
    std::ifstream ifs(path, std::ios::in | std::ios::binary);
    if (ifs.is_open()) {
        j = Json::parse(ifs);
        ifs.close();
        return true;
    }
    return false;
}

void LoadSaveFile::SaveFile(const char *file_name, const Json &j) {
     std::string path = GetDataPath(file_name);
     std::ofstream ofs(path, std::ios::out | std::ios::trunc | std::ios::binary);
    if (ofs.is_open()) {
        ofs << j;
        ofs.close();
    }
}
